from django.shortcuts import render
from rest_framework.generics import ListAPIView
from apps.home.models import NavModel,BannerModel
from fuguang.utils import constants,views
from apps.home.searial import NavSerializer,BanerSerializer
# Create your views here.

# 导航的视图

# 顶部导航
# class NavHeardListViews(ListAPIView):
#     queryset = NavModel.objects.filter(is_deleted=False,is_show=True,position=constants.NAV_HEARD).order_by('-id')[:constants.NAV_HEARD_SIZE]
#     serializer_class = NavSerializer
#
# # 底部导航
# class NavFooterListViews(ListAPIView):
#     queryset = NavModel.objects.filter(is_deleted=False, is_show=True, position=constants.NAV_FOOTER).order_by('-id')[:constants.NVA_FOOTER_SIZE]
#     serializer_class = NavSerializer
#
# # 轮播图视图
# class BannerListApiView(ListAPIView):
#     queryset = BannerModel.objects.filter(is_show=True, is_deleted=False).order_by('-id')[:constants.BANNER_SIZE]
#     serializer_class = BanerSerializer

    # lookup_field = 'pk'
    # lookup_url_kwarg = None

# 缓存视图
# 顶部导航
class NavHeardListViews(views.CacheListApiView):
    queryset = NavModel.objects.filter(is_deleted=False,is_show=True,position=constants.NAV_HEARD).order_by('-id')[:constants.NAV_HEARD_SIZE]
    serializer_class = NavSerializer

# 底部导航
class NavFooterListViews(views.CacheListApiView):
    queryset = NavModel.objects.filter(is_deleted=False, is_show=True, position=constants.NAV_FOOTER).order_by('-id')[:constants.NVA_FOOTER_SIZE]
    serializer_class = NavSerializer

# 轮播图视图
class BannerListApiView(views.CacheListApiView):
    queryset = BannerModel.objects.filter(is_show=True, is_deleted=False).order_by('-id')[:constants.BANNER_SIZE]
    serializer_class = BanerSerializer



